home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_337 / cmanual / miscellaneous.lzh / Miscellaneous / Example1.c < prev    next >
C/C++ Source or Header  |  1990-02-06  |  699b  |  33 lines

  1. /* Example1                                                   */
  2. /* This example shows how to allocate, and deallocate memory. */
  3.  
  4.  
  5. #include <exec/types.h>  /* Declares CPTR. */
  6. #include <exec/memory.h> /* Declares MEMF_CHIP. */
  7.  
  8.  
  9. main()
  10. {
  11.   /* Declare a pointer to the memory you are going to allocate: */
  12.   CPTR memory;
  13.  
  14.  
  15.   /* Allocate 150 bytes of Chip memory: */
  16.   memory = (CPTR) AllocMem( 150, MEMF_CHIP );
  17.  
  18.  
  19.   /* Have we allocated the memory successfully? */
  20.   if( memory == NULL )
  21.   {
  22.     printf("Could not allocate the memory!\n");
  23.     exit();
  24.   }
  25.  
  26.  
  27.   /* Do whatever you want to do with the memory! */
  28.   
  29.  
  30.   /* Free the memory we have previously allocated: */
  31.   FreeMem( memory, 150 );  
  32. }
  33.